//-----------------------------------------------------------------------
//  This file is part of the Microsoft Robotics Studio Code Samples.
// 
//  Copyright (C) Microsoft Corporation.  All rights reserved.
//
//  $File: SimpleSoccerPlayerTypes.cs $ $Revision: 1 $
//-----------------------------------------------------------------------

using Microsoft.Ccr.Core;
using Microsoft.Dss.Core.Attributes;
using Microsoft.Dss.ServiceModel.Dssp;
using System;
using System.Collections.Generic;
using W3C.Soap;
using referee = Microsoft.Robotics.Services.Simulation.SoccerReferee.Proxy;
using player = Microsoft.Robotics.Services.Simulation.SoccerPlayer.Proxy;
using Microsoft.Dss.Core.DsspHttp;
using Microsoft.Robotics.PhysicalModel;

namespace ProMRDS.SimpleSoccerPlayer
{
    
    /// <summary>
    /// SimpleSoccerPlayer Contract class
    /// </summary>
    public sealed class Contract
    {
        /// <summary>
        /// The Dss Service contract
        /// </summary>
        public const String Identifier = "http://www.promrds.com/promrds/2007/12/bettersoccerplayer.html";
    }


    /// <summary>
    /// trivially extend generic player state
    /// </summary>
    [DataContract]
    public class SimpleSoccerPlayerState : player.SoccerPlayerState
    {
        /// <summary>
        /// Last high level command executed 
        /// </summary>
        [DataMember]
        public SimpleSoccerPlayerCommand MostRecentCommand;

        /// <summary>
        /// Offset of detected ball from center of camera image
        /// </summary>
        [DataMember]
        public float BallOffset;

        [DataMember]
        public bool BallDetected;

        [DataMember]
        public Vector3 OpponentGoalRelativePosition;

        [DataMember]
        public int WebCamPollingIntervalInMs;

        [DataMember]
        public SoccerPlayerMode Mode;
    }
    [DataContract]
    public enum SoccerPlayerMode
    {
        FindBall,
        ReAlign,
        Kick,
        Approach
    }

    [DataContract]
    public enum SimpleSoccerPlayerCommand
    {
        ApproachBall = 0,
        FindBall,
        Defend,
        Kick,
        Realign
    }

    [DataContract]
    public class ExecuteCommandRequest
    {
        [DataMemberConstructor]
        [DataMember]
        public SimpleSoccerPlayerCommand Command;

        public ExecuteCommandRequest()
        {
        }

        public ExecuteCommandRequest(SimpleSoccerPlayerCommand command)
        {
            Command = command;
        }
    }

    public class ExecuteCommand : Update<ExecuteCommandRequest, DsspResponsePort<DefaultUpdateResponseType>>
    {
        public ExecuteCommand()
            : base()
        {
        }

        public ExecuteCommand(ExecuteCommandRequest command)
            : base(command)
        {
        }
    }

    public class Replace : Replace<SimpleSoccerPlayerState, DsspResponsePort<DefaultReplaceResponseType>>
    {
    }

    public class Get : Get<GetRequestType, DsspResponsePort<SimpleSoccerPlayerState>>
    {
    }

    [ServicePort]
    public class SimpleSoccerPlayerOperations : PortSet<DsspDefaultLookup, DsspDefaultDrop, Get, Replace, ExecuteCommand>
    {
    }
}
